home *** CD-ROM | disk | FTP | other *** search
- Path: news.mixcom.com!usenet
- From: elja.inc@mixcom.com (Mike McWhinney)
- Newsgroups: comp.lang.c
- Subject: Re: Please help: need to read lines in text file
- Date: Wed, 03 Apr 1996 14:36:38 GMT
- Organization: MIX Communications
- Message-ID: <31628cbe.1910456@news.mixcom.com>
- References: <315fe5d1.1121568@news.mixcom.com> <4joubrINNrdl@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: llggll.mixcom.com
- X-Newsreader: Forte Agent .99d/16.182
-
- c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
-
-
- >char *readline(char *filename, int n)
-
- [function contents deleted]
-
-
-
- Kazimir, would you need an fclose(stream) in the function readline()
- before the return statement?
-
- > if (nextchar == EOF || nextchar == '\n') {
- > buffer[charcount++] = '\0';
- > break;
- > } else
- > buffer[charcount++] = nextchar;
- > }
- fclose(stream); <-----------------Is this necessary?
- > return realloc(buffer, charcount);
- >
-
- I found that this function causes my program to work the first
- couple iterations, and then it produces unpredictable results.
- Also in main() don't you need to dynamical allocate storage
- space for 'str'? My program won't work unless I do something
- like:
-
- str = malloc(50);
-
- Please help!!!
-
- Thanks
-
- Mike
-
-